//
//  GLGameModel.m
//  QAQ打飞机
//
//  Created by admin on 15/8/28.
//  Copyright (c) 2015年 gl. All rights reserved.
//

#import "GLGameModel.h"

@implementation GLGameModel
#pragma mark -工厂方法
+(id)gameModelWithArea:(CGRect)gameArea size:(CGSize)heroSize
{

    GLGameModel *gm =[[GLGameModel alloc]init];
    gm.gameArea =gameArea;
    
    //初始化背景的边框
    gm.backFrame1 =gameArea;
    gm.backFrame2 =CGRectOffset(gameArea, 0, -gameArea.size.height);
    
    //初始化英雄
    gm.hero = [[GLHero alloc]initWithArea:gameArea size:heroSize];
    //初始化得分
    gm.gameScore =0;
    gm.bombsount =0;
    return gm;
}
#pragma mark 背景向下移动的方法
-(void)backMoveDown
{
   //假设每一次向下移动一个点
    self.backFrame1 = CGRectOffset(self.backFrame1, 0, 1);
    self.backFrame2 =CGRectOffset(self.backFrame2, 0, 1);
    CGRect topFrame = CGRectOffset(self.gameArea, 0, -self.gameArea.size.height);
    if (self.backFrame1.origin.y>=self.gameArea.size.height)
    {
        self.backFrame1 =topFrame;
    }
    else if(self.backFrame2.origin.y>=self.gameArea.size.height)
    {

        self.backFrame2 =topFrame;
    }
}
//敌机生成
-(GLEnemy *)createEnemyWithType:(GLEnemytype)type size:(CGSize)size
{

    return [GLEnemy enemyWithTyep:type area:self.gameArea size:size];
}
//物品生成
-(GLEquipVV *)createEquipWithType:(GLEquipType)type size:(CGSize)size
{
    return [GLEquipVV equipWithType:type area:self.gameArea size:size];

}

@end
